﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebServerInfo_Edit.aspx.vb"
    Inherits="Map.WebServerInfo_Edit" %>

<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/_common/styles/global.css"/>
    <link rel="stylesheet" type="text/css" href="/_common/styles/select.css"/>
    <link rel="stylesheet" type="text/css" href="/_nav/menu.css"/>
    <link rel="stylesheet" type="text/css" href="/_nav/tabs.css"/>
    <link rel="stylesheet" type="text/css" href="/_nav/nav.css"/>
    <link rel="stylesheet" type="text/css" href="/_grid/map_grid.css"/>
    <link rel="stylesheet" type="text/css" href="/_forms/styles/Form.css" />

    <script src="/_common/scripts/global.js" type="text/javascript"></script>

    <script src="/_common/scripts/Details.js" type="text/javascript"></script>

    <script src="/_controls/settings.aspx" type="text/javascript"></script>

    <script src="/_controls/util/util.js" type="text/javascript"></script>

    <script src="/_controls/datetime/date.js" type="text/javascript"></script>

    <script src="/_controls/datetime/time.js" type="text/javascript"></script>

    <script src="/_controls/number/number.js" type="text/javascript"></script>

    <script src="/_controls/lookup/map_lookup.js" type="text/javascript"></script>

    <script src="/_controls/find/find.js" type="text/javascript"></script>

    <script src="/_nav/menu.js" type="text/javascript"></script>

    <script src="/_forms/FormBase.js" type="text/javascript"></script>

    <script src="../Js/LMSCommon.js" type="text/javascript"></script>

    
        <script type="text/javascript">
        
        // 修改下拉框中的备选项
            function updateSelectItems(sName, sXML)
            {
                // 暂时处理 sXML = ""
                var oTable = document.getElementById("_" + sName + "_Table");
                var oInput = document.getElementById(sName);
                if (oInput && oTable)
                {
                    var xmlDom = new ActiveXObject("Microsoft.XMLDOM");

                    // 读取XML
                    xmlDom.loadXML(sXML);
                    var Nodes = xmlDom.documentElement.selectNodes("//ErpWebsiteList/ErpWebsite");

                    // 清除下拉框备选项
                    for (var i = oTable.rows.length - 1; i >= 0; i--)
                    {
                        oTable.deleteRow(i);
                    }

                    // 循环插入项
                    var oTr;
                    var oTd;

                    //重置下拉框状态
                    oInput.reset();
                    for (var i = 0; i < Nodes.length; i++)
                    {
                        // 插入项
                        oTr = oTable.insertRow();
                        oTd = oTr.insertCell();
                        oTd.val = Nodes[i].attributes.getNamedItem("identifiers").text;
                        oTd.innerText = Nodes[i].attributes.getNamedItem("SiteName").text;
                    }

                    if (Nodes.length > 0)
                    {
                        // 默认选中第一项
                        oInput.setValue(Nodes[0].attributes.getNamedItem("identifiers").text);
                        oInput.value = Nodes[0].attributes.getNamedItem("SiteName").text;
                    }
                }
            }
            //初始化
            function Init()
            {
                HideMenu();
                appForm._bAlert = false;
//                if (appForm.CpuQuantity.value == "")
//                {
//                    appForm.CpuQuantity.setValue("1");
//                }
            }
            function oprAfterSave()
            {
                // 处理返回结果
                try
                {
                    var xmlDom = XMLDOM();
                    xmlDom.loadXML(appForm.returnxml);
                    if (xmlDom.parseError.errorCode == 0)
                    {
                        if (xmlDom.documentElement.attributes.getNamedItem("result").text == "true")		// 返回成功
                        {
                            document.getElementById("WebSiteInfo").src = "WebServerInfo_WebSiteInfo.aspx";
                            alert("保存成功！");
                        }
                        else
                        {
                            alert("保存失败：" + xmlDom.documentElement.attributes.getNamedItem("errormessage").text);
                        }
                    }
                    else
                    {
                        alert("保存失败!");
                    }
                }
                catch (e)
                {
                }
                finally
                {
                    // 删除对象
                    delete (oHTTP);
                    delete (xmlDom);
                }

            }
            
            //刷新
            function Refresh()
            {
                openWaiting();
                window.setTimeout(InnerRefresh, 0);
            }
            
            //刷新
            function InnerRefresh()
            {
                var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
                var sUrl = "/ApplicationMap.aspx?functionid=00000302&actionid=02";
                oHTTP.open("POST", sUrl, false);
                oHTTP.send("<dataxml mysessionstate=\"" + document.all["___MYSESSIONSTATE"].value + "\"><userdataxml></userdataxml></dataxml>");

                // 要求返回xml格式<xml result="true/flase" errormessage="错误信息！">任意正确格式的xml</xml>。
                var xmlReturn = oHTTP.responseText;
                delete (oHTTP);

                if (xmlReturn != "")
                {
                    var xmlDom = XMLDOM();
                    xmlDom.loadXML(xmlReturn);

                    if (xmlDom.parseError.errorCode == 0)
                    {

                        var serverName = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ServerName");
                        if (serverName)
                        {
                            appForm.ServerName.setValue(serverName.text);
                        }

                        var ip = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/Ip");
                        if (ip)
                        {
                            appForm.Ip.setValue(ip.text);
                        }

                        var isAddInDomain = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/IsAddInDomain");
                        if (isAddInDomain && appForm.IsAddInDomain)
                        {
                            var oTable = document.getElementById("_IsAddInDomain_Table");
                            var oInput = document.getElementById("IsAddInDomain");
                            if (oInput && oTable)
                            {
                                oInput.setValue(isAddInDomain.text);
                                oInput.value = isAddInDomain.text;
                            }
                        }

                        var cpuType = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/CpuType");
                        if (cpuType)
                        {
                            appForm.CpuType.setValue(cpuType.text);
                        }

                        var cpuQuantity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/CpuQuantity");
                        if (cpuQuantity)
                        {
                            appForm.CpuQuantity.setValue(cpuQuantity.text);
                        }

                        var hardDiskType = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/HardDiskType");
                        if (hardDiskType)
                        {
                            appForm.HardDiskType.setValue(hardDiskType.text);
                        }

                        var memoryCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/MemoryCapacity");
                        if (memoryCapacity)
                        {
                            appForm.MemoryCapacity.setValue(memoryCapacity.text);
                        }

                        var osDrive = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/OsDrive");
                        if (osDrive)
                        {
                            appForm.OsDrive.setValue(osDrive.text);
                        }

                        var osDriveCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/OsDriveCapacity");
                        if (osDriveCapacity)
                        {
                            appForm.OsDriveCapacity.setValue(osDriveCapacity.text);
                        }

                        var osDriveFreeCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/OsDriveFreeCapacity");
                        if (osDriveFreeCapacity)
                        {
                            appForm.OsDriveFreeCapacity.setValue(osDriveFreeCapacity.text);
                        }

                        var erpDrive = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDrive");
                        if (erpDrive)
                        {
                            appForm.ErpDrive.setValue(erpDrive.text);
                        }

                        var erpDriveTotalCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDriveTotalCapacity");
                        if (erpDriveTotalCapacity)
                        {
                            appForm.ErpDriveTotalCapacity.setValue(erpDriveTotalCapacity.text);
                        }

                        var erpDriveFreeCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDriveFreeCapacity");
                        if (erpDriveFreeCapacity)
                        {
                            appForm.ErpDriveFreeCapacity.setValue(erpDriveFreeCapacity.text);
                        }

                        var osName = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/OsName");
                        if (osName)
                        {
                            appForm.OsName.setValue(osName.text);
                        }

                        var isSixFourOs = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/IsSixFourOs");
                        if (isSixFourOs)
                        {
                            var oTable = document.getElementById("_IsSixFourOs_Table");
                            var oInput = document.getElementById("IsSixFourOs");
                            if (oInput && oTable)
                            {
                                oInput.setValue(isSixFourOs.text);
                                oInput.value = isSixFourOs.text;
                            }
                        }

                        var iisVersion = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/IisVersion");
                        if (iisVersion)
                        {
                            appForm.IisVersion.setValue(iisVersion.text);
                        }

                        var ErpWebsiteList = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpWebsiteList");
                        if (ErpWebsiteList)
                        {
                            updateSelectItems("ErpWebsiteIdentifiers", ErpWebsiteList.xml);
                        }

                        var erpWebsiteIdentifiers = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpWebsiteIdentifiers");
                        if (erpWebsiteIdentifiers)
                        {
                            appForm.ErpWebsiteIdentifiers.setValue(erpWebsiteIdentifiers.text);
                        }
                        
                        //更新站点相关的信息
                        ERPWebSiteSelectedChange();
                        
                        document.getElementById("WebSiteInfo").src = "WebServerInfo_WebSiteInfo.aspx?xml=/LMS/ConfigManage/WebServerInfo_TempWebSiteInfo.xml";
                    }
                    else
                    {
                        alert('刷新失败!');
                    }
                }

                closeWaiting();

            }
            //ERP网站选择改变事件
            function ERPWebSiteSelectedChange()
            {
                var erpWebsiteIdentifiers = appForm.ErpWebsiteIdentifiers.returnValue;
                var _Index=document.getElementById("ErpWebsiteIdentifiers").getValueIndex(erpWebsiteIdentifiers);

                if (erpWebsiteIdentifiers == "" |_Index < 0)
                {
                    appForm.ErpDrive.setValue("");
                    appForm.ErpDriveTotalCapacity.setValue("");
                    appForm.ErpDriveFreeCapacity.setValue("");
                    appForm.ErpWebsiteIdentifiers.setValue("");
                }
                else
                {
                    var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
                    var sUrl = "/ApplicationMap.aspx?functionid=00000302&actionid=03";
                    oHTTP.open("POST", sUrl, false);
                    oHTTP.send("<dataxml mysessionstate=\"" + document.all["___MYSESSIONSTATE"].value + "\"><userdataxml><ErpWebsiteIdentifiers>"+erpWebsiteIdentifiers+"</ErpWebsiteIdentifiers></userdataxml></dataxml>");

                    // 要求返回xml格式<xml result="true/flase" errormessage="错误信息！">任意正确格式的xml</xml>。
                    var xmlReturn = oHTTP.responseText;
                    delete (oHTTP);
                    
                    if (xmlReturn == "")
                    {
                    }
                    else
                    {
                        var xmlDom = new XMLDOM();
                        xmlDom.loadXML(xmlReturn);
                        if (xmlDom.parseError.errorCode == 0)
                        {
                            var erpDrive = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDrive")
                            if (erpDrive)
                            {
                                appForm.ErpDrive.setValue(erpDrive.text);
                            }

                            var erpDriveTotalCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDriveTotalCapacity")
                            if (erpDriveTotalCapacity)
                            {
                                appForm.ErpDriveTotalCapacity.setValue(erpDriveTotalCapacity.text);
                            }

                            var erpDriveFreeCapacity = xmlDom.documentElement.selectSingleNode("/Lms_Svr_WebInfo/ErpDriveFreeCapacity")
                            if (erpDriveFreeCapacity)
                            {
                                appForm.ErpDriveFreeCapacity.setValue(erpDriveFreeCapacity.text);
                            }
                        }
                        else
                        {
                            alert("取ERP网站" + appForm.ErpWebsiteIdentifiers.value + "的部署信息失败！");
                        }
                    }

                }           

            }
    </script>

</head>
<body ms_positioning="GridLayout" style="padding: 10px;" onload="Init()">
    <table style="font-size: 9pt;" height="100%" cellspacing="0" cellpadding="0" width="100%">
        <tr height="1">
            <td>
                <mnu:AppFormMenu ID="appFormMenu" runat="server"/>
            </td>
        </tr>
        <tr>
            <td style="height: 5px">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                <cnt:AppForm ID="appForm" runat="server" ProcessType="xmlhttp" OnAfterSave="oprAfterSave()"/>
            </td>
        </tr>
    </table>
</body>
</html>
